package com.meringer.beans;

import java.util.List;

import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

import com.meringer.beans.ejb.CarEJB;
import com.meringer.entities.Car;
import com.meringer.entities.CarModel;
import com.meringer.utils.CarAndModel;

@ManagedBean(name = "carBean")
@RequestScoped
public class CarBean {
	@EJB
	CarEJB carEJB;
	private List<CarModel> filteredCars;  
	public List<CarAndModel> getCars(){
		return carEJB.getCars();
	}
	public List<CarModel> getFilteredCars() {  
        return filteredCars;  
    }  
  
    public void setFilteredCars(List<CarModel> filteredCars) {  
        this.filteredCars = filteredCars;  
    }  
    public void cellCar(Car car){
    	int soldFor = carEJB.cellCar(car);
    	FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "You have successfully sold your car for: "+soldFor, null));
    }
}
